package com.itheima.util;

import com.itheima.domain.User;

import javax.servlet.http.HttpServletRequest;

/**
 * Created with IntelliJ IDEA.
 * @Author: auuuu4
 * @Date: 2024/07/10/11:17
 * @Description:
 */
public class RequestSessionUtil {

    private static final String USER_INFO_KEY = "USER_SESSION";
    public static void setAttribute(HttpServletRequest request,String key,Object value){
        request.getSession().setAttribute(key,value);
    }
    public static Object getAttribute(HttpServletRequest request,String key){
        return request.getSession().getAttribute(key);
    }

    public static User getUserInfo(HttpServletRequest request){
        return (User) request.getSession().getAttribute(USER_INFO_KEY);
    }
    public static void setUserInfo(HttpServletRequest request,User user){
        request.getSession().setAttribute(USER_INFO_KEY,user);
    }
}
